package com.example.lanqiaodemo1.TestFour;

import com.example.lanqiaodemo1.TestFour.Account;

import java.util.Date;

//Account的子类定期账户类
public class DepositAccount extends Account {
    private int term;
    public void setTerm(int term){
        this.term=term;
    }
    public int getTerm(){
        return this.term;
    }
    public DepositAccount(String id,String name,double balance,int term){
        super(id,name,balance);
        this.term=term;
    }
    @Override
    public void deposite(double money){
        System.out.println("定期账户不能再次存钱");
    }

    @Override
    public void withdraw(double money){
        Date now=new Date();
        int time=(int)(now.getTime()-this.getDatetime().getTime())/1000/3600/24;
        if(time<(this.term)*365){
            System.out.println("定期存款不到期，不能支取");
        }
        if(money!=this.getBalance()){
            System.out.println("定期存款必须一次全部支取");
        }
        this.setBalance(0);
    }

    @Override
    public void changeMoney(Account other,double money){
        System.out.println("定期账户不能转账");
    }
}
